package com.zhaopin.filter;


import com.zhaopin.common.Save;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
public class TokenFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request= (HttpServletRequest) servletRequest;
        String token= request.getHeader("content-type");
        //第一种，将token保存在服务器中
        if (Save.tokens.contains(token)){
            filterChain.doFilter(request,servletResponse);
        }
        return;
    }

    @Override
    public void destroy() {

    }
}
